package com.baizhi.action;

import com.baizhi.entity.Emp;
import com.baizhi.entity.User;
import com.baizhi.service.EmpService;
import com.baizhi.service.impl.EmpServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

import java.util.List;

public class EmpAction {
    //把集合放到request作用域中
    private List<Emp> emps;
    private int id;
    private Emp emp;

    public String queryAll(){
        EmpService es = new EmpServiceImpl();
        emps = es.queryAllEmps();
        return "success";
    }

    //删除
    public String remove(){
        EmpService es = new EmpServiceImpl();
        es.removeEmp(id);
        System.out.println("------删除完成-------");
        return "success";
    }
    //添加员工
    public String add(){
        EmpService es = new EmpServiceImpl();
        es.registEmp(emp);
        System.out.println("------添加完成-------");
        return "success";
    }
    //查询单个员工
    public String queryOne(){
        EmpService es = new EmpServiceImpl();
        emp = es.queryById(id);
        return "success";
    }

    //修改
    public String change(){
        EmpService es = new EmpServiceImpl();
        es.changeEmp(emp);
        return "success";
    }

    public Emp getEmp() {
        return emp;
    }

    public void setEmp(Emp emp) {
        this.emp = emp;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public List<Emp> getEmps() {
        return emps;
    }

    public void setEmps(List<Emp> emps) {
        this.emps = emps;
    }
}
